<?php

class TypeattrController extends CommonController{
	private $_model;
	public function __init(){
		$this->_model = K('Typeattr');
	}
	public function index(){
		
		$data = $this->_model->get_all_attr();
//		p($data);
		$this->assign('data',$data);
		
		$this->display();
	}
	//添加属性
	public function addattrlist(){
		if(IS_POST){
			$this->_model->add_attrlist();
			$this->success('添加成功',U('Typeattr/index'));
		}
		$this->display();
	}
	//修改
	public function editlist(){
		if(IS_POST){
			if($this->_model->update_attr(array('taid'=>Q('post.taid',0,'intval')))){				
				$this->success('修改成功',U('Typeattr/index'));
			}else{
				$this->error($this->_model->error);
			}		
		}
		//获取旧数据
		$oldData = $this->_model->get_one_attr(array('taid'=>Q('get.taid',0,'intval')));
		$this->assign('oldData',$oldData);
		
		
		$this->display();
	}
	//删除
	public function del(){
		if($this->_model->del_attr(Q('get.taid',0,'intval')));
			$this->success('删除成功');
		
		$this->error($this->_model->error);
	}
	
	
}
